package com.haircut.project.controller.statistics;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.haircut.project.service.record.IRecordService;
import com.haircut.project.vo.statistics.*;
import com.modular.result.PageResult;
import com.modular.result.RspMessage;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/b/stati")
public class StatisticsController {
    @Autowired
    private IRecordService recordService;

    /**
     * 查询分类列表
     * @return
     */
    @ApiOperation(value = "核查数据")
    @GetMapping("findSalarystatistics")
    public RspMessage<List<SalaryDeptResVo>> findSalarystatistics(){
        return RspMessage.success(recordService.findSalaryStatic());
    }

    /**
     * 查询分类列表
     * @return
     */
    @ApiOperation(value = "查询项目排行榜")
    @PostMapping("findProjectRankPage")
    public RspMessage<PageResult<StatisProjectVo>> findProjectRankPage(@RequestBody  SalaryReqVo reqVo){
        if(ObjectUtil.isNull(reqVo.getStartDate())){
            Date currDate = DateUtil.date();
            reqVo.setStartDate(DateUtil.beginOfDay(currDate));
            reqVo.setEndDate(DateUtil.endOfDay(currDate));
        }
        return RspMessage.success(recordService.findProjectRankPage(reqVo));
    }

    /**
     * 查询分类列表
     * @return
     */
    @ApiOperation(value = "查询用户排行榜")
    @PostMapping("findUserRankPage")
    public RspMessage<PageResult<StatsUserVo>> findUserRankPage(@RequestBody  SalaryReqVo reqVo){
        if(ObjectUtil.isNull(reqVo.getStartDate())){
            Date currDate = DateUtil.date();
            reqVo.setStartDate(DateUtil.beginOfDay(currDate));
            reqVo.setEndDate(DateUtil.endOfDay(currDate));
        }
        return RspMessage.success(recordService.findUserRankPage(reqVo));
    }



}
